home *** CD-ROM | disk | FTP | other *** search
/ Champak 31 / Volume 31 - JOGO DISK .iso / Games / christmas_attack.swf / scripts / DefineSprite_170_swarm3 / frame_1 / PlaceObject2_169_1 / CLIPACTIONRECORD onClipEvent(enterFrame).as
Text File  |  2007-01-15  |  1KB  |  42 lines

  1. onClipEvent(enterFrame){
  2.    if(_root.pause == 0)
  3.    {
  4.       targetVectorX = 320 - _parent._x;
  5.       targetVectorY = 0;
  6.       hypVector = Math.sqrt(targetVectorX * targetVectorX + targetVectorY * targetVectorY);
  7.       targetThetaX = Math.asin(targetVectorX / hypVector) / 0.017453292519943295;
  8.       targetThetaY = Math.acos(targetVectorY / hypVector) / 0.017453292519943295;
  9.       if(targetVectorY < 0)
  10.       {
  11.          targetTheta = 180 - targetThetaX;
  12.       }
  13.       else
  14.       {
  15.          targetTheta = targetThetaX;
  16.       }
  17.       if(Math.abs(targetTheta - rota) < 10 || Math.abs(targetTheta - rota) > 350)
  18.       {
  19.          rota = targetTheta;
  20.          turning = 0;
  21.       }
  22.       if(rota < targetTheta)
  23.       {
  24.          if(turning < turnSpeed)
  25.          {
  26.             turning++;
  27.          }
  28.       }
  29.       else if(rota > targetTheta)
  30.       {
  31.          if(turning > - turnSpeed)
  32.          {
  33.             turning--;
  34.          }
  35.       }
  36.       rota += turning;
  37.       xSpeed += accel * Math.sin(rota * 3.141592653589793 / 180);
  38.       xSpeed /= spdx;
  39.       _parent._x += xSpeed;
  40.    }
  41. }
  42.